package com.itany.corejava.code07_常用类.泛型;

/**
 * @author MissChen
 * @date 2024年03月02日 15:18
 */
public class User implements CompareInterface<User>{
    private String name;
    private int age;

    public User(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int compareTo(User user) {
        if(this.getName().length()>user.getName().length()){
            return 1;
        }else if(this.getName().length()<user.getName().length()){
            return -1;
        }
        return 0;
    }
}
